package com.boat.framework.common.config;

import com.boat.framework.common.util.SpringUtils;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * 获取配置参数
 * @author 周江
 *
 */
@Slf4j
public class ConfigProps {

	public static String getString(String key) {
		return SpringUtils.getEnvironment().getProperty(key);
	}

	public static String getString(String key, String defaultValue) {
		String property = getString(key);
		return StrUtil.isBlank(property) ? defaultValue : property;
	}

	public static Integer getInteger(String key) {
		String property = getString(key);
		return StrUtil.isBlank(property) ? null : Integer.valueOf(property);
	}

	public static Integer getInteger(String key, Integer defaultValue) {
		String property = getString(key);
		return StrUtil.isBlank(property) ? defaultValue : Integer.valueOf(property);
	}

	public static Boolean getBoolean(String key) {
		String property = getString(key);
		return StrUtil.isBlank(property) ? null : Boolean.valueOf(property);
	}

	public static Boolean getBoolean(String key, Boolean defaultValue) {
		String property = getString(key);
		return StrUtil.isBlank(property) ? null : Boolean.valueOf(property);
	}
}
